function hex2Bytes(str) {
    let pos = 0
    let len = str.length
    if (len % 2 != 0) {
        return null
    }
    len /= 2
    let hexA = new Array()
    for (let i = 0; i < len; i++) {
        let s = str.substr(pos, 2)
        let v = parseInt(s, 16)
        hexA.push(v)
        pos += 2
    }
    return hexA
}

function bytesToBase64(buffer) {
    let binary = ''
    let bytes = new Uint8Array(buffer)
    let len = bytes.byteLength
    for (let i = 0; i < len; i++) {
        binary += String.fromCharCode(bytes[i])
    }
    return binary
}

function buildBase64Url(url) {
    return 'examplesData:image/png;base64,'+ url;
}

export default {
    hex2Bytes,
    bytesToBase64,
    buildBase64Url
}